define(['jquery', 'jquery-validation', 'jquery-json', 'bootstrap/js/bootstrap-transition', 'bootstrap/js/bootstrap-modal'], function ($) {

	function getURLParameter(name) {
	    return decodeURI(
	        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
	    );
	}


	
	$(document).ready(function(){
		$("#newNodeForm").submit(function() {
			requestData=$.toJSON({path: getURLParameter("path"),name: $("input[name=name]").val()});
			$.ajax({
				url: 'service/addNode.json',
				async: true, /* If set to non-async, browser shows page as "Loading.."*/
				cache: false,
//				timeout: 5000, /* Timeout in ms */
				type: 'POST',
				contentType: 'application/json; charset=utf-8',
				dataType: 'json',
				data: requestData,
				success: function (data) {
					$("#openUp").modal("hide");
					alert("AJAX Succeed!");
					console.log(data);
				},
				error: function (data) {
					alert("AJAX Sucked!");
					console.log(data);
				}
			});
			return false;
		});
		
	});
	return;
});
